package collection;

import java.util.Arrays;
import java.util.List;

/** 数组转换为集合 */
public class ArrayToList {
    public static void main(String[] args) {
        String[] array = {"one","two","three","four","five"};
        //System.out.println(array);直接输出array是输出数组在内存的地址
        System.out.println("array："+ Arrays.toString(array));//将数组转换成字符串输出用Arrays.toString(数组名)
        //数组转换成集合
        List<String> list = Arrays.asList(array);
        System.out.println("list:"+list);

        array[1] = "six";
        System.out.println("arrays:"+Arrays.toString(array));
        System.out.println("list:"+list);

        list.set(2,"seven");
        System.out.println("array:"+Arrays.toString(array));
        System.out.println("list:"+list);



        //
        //list.add("!!!");//UnsupportedOperationException

    }
}
